General Overview:
You will be creating a time class,
an alarm clock, a radio and a radio alarm clock.
This
is only as simulation; your radio alarm clock will not actually function.
Files to be turned in:
Specifications:
Enumeration ETimeFormat
- Add
an enumeration for the Time Format (Universal and Standard). This enumeration should be created in
the same file as CTime but before the class
definition.
enum ETimeFormat
{
Universal = 0,
Standard
};
Class CTime Your CTime class should
be based on the Time class in your book on pages 491-494.
Changes from the books Time Class:
·
Change the variable names and any other
programming style to fit what you have been taught in class. For example make the class name CTime instead of Time.
·
Add a member variable named m_Format
of type ETimeFormat.
The member variable should default to Standard.
·
Add a public set function for m_Format.
·
Overload the stream insertion operator to
display the time in the format indicated by m_Format. You are still required to use the PrintUniversial and PrintStandard
functions; they should now be private.
Class Alarm Clock Inherits from (is a) CTime.
- The
alarm clock is unique in the fact that while it is a CTime,
it also keeps track of another time; the alarm time. To keep track of the alarm time, add a
private member variable of type CTime named m_AlarmTime.
- Add a
public member function to the class to set the alarms time (SetAlarm). This
function should take the same parameters as the SetTime() in the time
class. As a matter of fact it
should call that function on the m_AlarmTime
object.
- Override
the inherited function SetFormat(). This
function should now set the format for the time and the alarm time.
- Override
the inherited function PrintUniversial (). This function should now print the time
in the military format for both the time and the alarm time. Make your output describe which time is
which.
- Override
the inherited function PrintStandard(). This function
should now print the time in the standard format for both the time and the
alarm time. Make your output
describe which time is which.
- Overload
the stream insertion operator to display the time & alarm time in the
format indicated by m_Format.
Enumeration EBand
- Add
an enumeration for the band, AM and FM.
This enumeration should be created in the same file as CRadio but before the class definition.
- Overload
the stream insertion operator to display the band.
enum EBand
{
AM = 0,
FM
};
Class Radio
- Static
Constants: remember to initialize at file level. All of them should be
integers.
- MAX_FREQUENCY
= 110
- MIN_FREQUENCY
= 85
- MAX_AMPLITUDE
= 1750
- MIN_AMPLITUDE
= 500
- MAX_VOLUME
= 100
- Add a
default constructor that takes two parameters (band and volume). Default the band to FM, the station
to 100.1 and the volume to 30.
- Add a
set station function (SetStation) that accepts a
new station as its only parameter.
This function should do bounds checking to make sure the station is
within an expectable frequency or amplitude. This function should return true if the
new station value is accepted false otherwise.
- Add a
set volume (SetVolume) function that accepts a
new station as its only parameter.
This function should do bounds checking to make sure the volume is
greater than or equal to 0 and less than or equal to MAX_VOLUME. This
function should return true if the new volume value is accepted false otherwise.
- Add a
set band (SetBand) function that will set the
band to AM or FM. This function
should take one parameter of type EBand. When switching from one band to
another, be sure to set the station correctly. AM = ((FM-85)*50)+500 and FM = ((AM-500)/50)+85.
- Overload
the stream insertion operator to display the radio.
- The
class should contain the following private data members.
- float
m_Station;
- int m_Volume;
- EBand m_Band;
Class Radio Alarm Clock inherits form CRadio and CAlarmClock (is a
radio and is an alarm clock)
1.
Add a default constructor that will default the band to
FM, the station to 100.1 and the volume to 30.
2.
Overload the stream insertion operator to display the
radio alarm clock.